package cn.spream.common.util;

/**
 * 验证工具类
 * Created with IntelliJ IDEA.
 * User: shaojiaxin
 * Date: 13-8-19
 * Time: 下午5:12
 * To change this template use File | Settings | File Templates.
 */
public class CheckUtils {

    /**
     * 验证是否是邮箱
     *
     * @param email
     * @return
     */
    public static boolean isEmail(String email) {
        if (email != null && email.trim().length() > 0) {
            return Regexp.EMAIL.matcher(email).matches();
        }
        return false;
    }

    /**
     * 验证是否有数字或者字母组成
     *
     * @param alphanumeric
     * @return
     */
    public static boolean isAlphanumeric(String alphanumeric) {
        if (alphanumeric != null && alphanumeric.trim().length() > 0) {
            return Regexp.ALPHANUMERIC.matcher(alphanumeric).matches();
        }
        return false;
    }

    /**
     * 验证字符串长度是否在指定的区间之内
     *
     * @param target
     * @param min
     * @param max
     * @return
     */
    public static boolean isRange(String target, int min, int max) {
        if (target != null && target.length() >= min && target.length() <= max) {
            return true;
        }
        return false;
    }

}
